<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link rel="stylesheet" href="../../css/index.css">
		<link rel="stylesheet" href="../../layui/css/layui.css" />
<title>系统公告</title>
</head>
<body>

	<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
	    <div class="layui-form-item">
			<label class="layui-form-label">角色名称:</label>
			<div class="layui-input-block">
				<input type="text" name="name" id="name" lay-verify="name" autocomplete="off" placeholder="请输入角色名称" class="layui-input">
			</div>
		</div>
    
    	<div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">角色描述</label>
		    <div class="layui-input-block">
		      <textarea name="description" id="description" placeholder="请输入角色描述内容" class="layui-textarea"></textarea>
		    </div>
		</div>
  	
    <div class="layui-form-item layui-hide">
      <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
      <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
    </div>
  </div>
	
	
</body>

<script type="text/javascript" src="../../layui/layui.all.js" charset="utf-8"></script>
<script>
layui.use(['table','jquery','form','layer'], function(){
  
  var table = layui.table;
  var $ = layui.jquery;
  var form=layui.form;
  var layer = layui.layer;
  
  	//监听点击提交
    form.on('submit(layuiadmin-app-form-submit)', function(data){
      var field = data.field; //获取提交的字段
      var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引 

		
		
	    var name = $("#name").val();
		var description = $("#description").val();
	
		var obj = {
			"name":name,
			"description":description,
		};
		var param = JSON.stringify(obj);
		//alert(param)
		$.ajax({
			url:"../../adminrole/addRole",
			type:"POST",
			data:param,
			dataType : "json",
			xhrFields :{
				withCredentials: true
			},
			contentType:'application/json;charset=UTF-8',
			success:function(e){
				if(e.code == 0){
					layer.msg("添加成功",{icon:6}); 
				}else{
					layer.msg("添加失敗",{icon:5});
				}
				setTimeout(function(){
						parent.layui.table.reload('LAY-app-content-list'); //重载表格
     					parent.layer.close(index); //再执行关闭 
						parent.layui.table.reload('role'); //重载表格
				},1*1000)
			},
			error:function(e){
				layer.msg("添加失敗",{icon:5});
				
			}
		})
     	return false;
   });
  
  
  
});
</script>

</html>